import java.io.IOException;
import java.io.RandomAccessFile;

//Class containing operations of datatype i4
public class i4 extends datatype implements read,write{

	public void write(String data, int length) throws IOException
	{
		//System.out.println("i4 write called");
		RandomAccessFile fi= new RandomAccessFile(heap.f,"rw");
		fi.seek(heap.f.length());
		int b=Integer.parseInt(data);
		fi.writeInt(b);
		fi.close();
	}
	public String read(int length) throws IOException
	{
		String str;
		RandomAccessFile fip= new RandomAccessFile(heap.f, "rw");
		fip.seek(heap.readpointer);
		str=""+fip.readInt();
		heap.readpointer+=4;
		return str;
	}
	public int compares(String value1,String value2) throws IOException
	{
		int result=0;
		int record1=Integer.parseInt(value1);
		int record2=Integer.parseInt(value2);
		result = record1>record2?1:record1<record2?2:0;
		return result;

	}

}
